package mysql

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	GoodsTitle string  `gorm:"type:varchar(100);not null;comment:商品标题"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品单价"`
	GoodsStock int     `gorm:"type:int;not null;comment:商品数量"`
	GoodsState int     `gorm:"type:tinyint(1);not null;comment:商品状态:1:已上架;2:已下架;3:售卖中;4:已售空"`
}

func (g *Goods) Info(goodsId int) error {
	return DB.Where("id = ?", goodsId).First(&g).Error
}
func (g *Goods) Create() error {
	return DB.Create(&g).Error
}
